package com.yichen.music;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.music.Utils.BillboardUtil;
import com.yichen.util.MusicUtil;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;

/**
 * 获取榜单列表
 * 
 * @author yangyong
 * 
 */
public class BillboardList extends ListActivity implements OnItemClickListener {
	List<String> name_data;
	List<Map<String, String>> data_base;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		BillboardUtil billboard_cate = new BillboardUtil();
		data_base = billboard_cate.getBillboardList_name_id();// 获取所有榜单

		name_data = new ArrayList<String>();// 获取榜单的名字
		for (Map<String, String> map : data_base) {
			name_data.add(map.get("billboard_name"));
		}

		ArrayAdapter<String> data_adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, name_data);

		this.setListAdapter(data_adapter);
		this.getListView().setOnItemClickListener(this);

	}

	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		// TODO Auto-generated method stub
		Intent re_intent = new Intent();
		re_intent.putExtra("billboard_id",
				data_base.get(arg2).get("billboard_id"));// 下一个页面需要id作为查询条件
		re_intent.setClass(this, BillboardInfo.class);
		startActivity(re_intent);

		// System.out.println(data_base.get(arg2).get("billboard_id"));//获取榜单的ID

	}
}
